package com.hulk.rpc.param;

import com.hulk.rpc.invoke.ServiceInvokeFactory;

import java.util.Objects;

/**
 * 服务端专用，通过serviceId获取MethodParam.class
 */
public class MethodParamClassResolver {
  private final ServiceInvokeFactory invokerFactory;

  public MethodParamClassResolver(ServiceInvokeFactory invokerFactory) {
    Objects.requireNonNull(invokerFactory, "invokerFactory is null");
    this.invokerFactory = invokerFactory;
  }

  /**
   * 服务端专用，通过serviceId获取MethodParam.class
   */
  public Class<? extends MethodParam> getMethodParamClass(int serviceId) {
    return invokerFactory.get(serviceId).getMethodParamClass();
  }
}
